package com.sk.sourcecircle.activity.mine.act;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.sk.sourcecircle.R;
import com.sk.sourcecircle.adapter.PreviewBannerAdapter;
import com.sk.sourcecircle.base.BaseActivity;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by sk on 2018/1/6.
 */

public class PreviewViewpagerActivity extends BaseActivity {

    @BindView(R.id.view_pager)
    ViewPager viewPager;
    @BindView(R.id.tv_postion)
    TextView tvPostion;
    @BindView(R.id.save)
    TextView save;
    private int pos;
    private ArrayList<String> list;
    private int type;

    @Override
    protected int getContentView() {
        return R.layout.activity_preview_viewpager;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStatusBarTintResource(R.color.navigationBar_color);
        type = getIntent().getIntExtra("type", 1);
        pos = getIntent().getIntExtra("pos", 0);
        list = getIntent().getStringArrayListExtra("list");
        Log.v("tvPostion", list.get(0));
        PreviewBannerAdapter previewBannerAdapter = new PreviewBannerAdapter(list, mContext);
        viewPager.setAdapter(previewBannerAdapter);
        viewPager.setCurrentItem(pos);
        tvPostion.setText(pos + 1 + "/" + list.size());

        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                tvPostion.setText(position + 1 + "/" + list.size());
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }


    @OnClick({R.id.view_pager})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.save:
                break;
        }
    }
}
